package com.leo.slice;

import com.leo.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;

public class ShadowAbilitySlice extends AbilitySlice implements Component.ClickedListener {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_shadow);
        findComponentById(ResourceTable.Id_shadowLayout_bar_left).setClickedListener(this);
        findComponentById(ResourceTable.Id_ShadowLayoutIntent).setClickedListener(this);
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }

    @Override
    public void onClick(Component component) {
        switch (component.getId()) {
            case ResourceTable.Id_shadowLayout_bar_left:
                terminate();
                break;
            case ResourceTable.Id_ShadowLayoutIntent:
                Intent intent = new Intent();
                Intent.OperationBuilder builder = new Intent.OperationBuilder()
                        .withBundleName("com.leo.shadowlayout")
                        .withAbilityName("com.leo.StartShowAbility");
                intent.setOperation(builder.build());
                startAbility(intent);
                break;
        }
    }
}
